/** @jsxImportSource @emotion/react */
import * as React from "react";
import { OriginalViewProps, } from "../../common/base";
import {config设备概况, EntranceSetup} from "./orcBase";
import { createItem, } from "../../common/eHelper";
import { useRecordListSubr} from "../../hook/useRecordListSub";
import {PropertySolidify} from "../../industrial/EditorFeature";
import {IPipingUnitEntity} from "../../../comp/ChoosePipingUnits";
import {ConclusionSteelTh, } from "./Conclusion";
import {ProjectListRq} from "../../vessel/editProj";
import {DeviceSurvey} from "../../elevator/editor";
import {ConclusionAppendix} from "../../gas/plastics/ConclusionAppendix";
import {FitnessService, FitnessServiceTbl} from "./FitnessService";
import {Explanatory} from "./Explanatory";

//依照"allpage": [】减去 "addpage": [】,  contlist【】是可选的目录顺序。
export const Projects默认=[
    {name:'公用管道全面检验结论报告',do:true,ha:'Conclusion'},
    {name:'公用管道全面检验结论报告附页', ha:'ConclusionAppendix',na:true},
    {name:'公用管道合于使用评价结论报告',do:true,ha:'FitnessService'},
        //续页（一）
    {name:'合于使用评价续页二',ml:'公用管道合于使用评价结论报告续页（二）',ha:'Explanatory',na:true},
    {name:'资料审查报告',ha:''},
    {name:'应力校核报告',ha:''},
    {name:'剩余强度评估报告',ha:''},
    {name:'超标缺陷安全评定报告',ha:''},
    {name:'剩余寿命预测报告',ha:''},
    {name:'材料适用性评价报告',ha:''},
    {name:'腐蚀防腐系统评价报告（一）',ha:''},
    {name:'腐蚀防腐系统评价报告（二）',ha:''},
    {name:'综合评价报告',ha:''},
    {name:'管道特性表', do:true,ha:'Characteristics'},
    // {name:'管道单线图', ha:'PipeLineDiagram',},
    {name:'其他', ha:''},
];

const recordPrintList =[
    createItem('Entrance', <EntranceSetup/>),
    createItem('ProjectList', <ProjectListRq config={Projects默认}  label={'目录页'}/>),
    createItem('Survey', <DeviceSurvey config={config设备概况} label={'公用管道全面检验结论报告-设备概况'}/>),
    createItem('Conclusion', <ConclusionSteelTh label={'公用管道全面检验结论报告-下结论'}/>),
    createItem('FitnessService', <FitnessService label={'公用管道合于使用评价结论报告'}/>),
    createItem('ConclusionAppendix', <ConclusionAppendix table={'附页表'} label='公用管道全面检验结论报告附页'/>),

    createItem('FitnessServiceTbl', <FitnessServiceTbl label={'公用管道合于使用评价结论报告续页（一）'}/>),
    createItem('Explanatory', <Explanatory label={'公用管道合于使用评价结论报告续页（二）'} desc='发现问题及处理意见'/>),
    createItem('Solidify', <PropertySolidify label={'管道特性表-管理器'} filterCB={modelToRepData}/>),
    // createItem('LineDiagram', <SingleLineDiagram />),
    createItem('_Controller',  <></>),
];


//针对这个模板CharacteristRow()需要显示字段： 从Relay模型获取报告才需要的字段：svp pa只保存有用到的字段：但是PropertySolidify必须提取全面useLazyLoadQuery<typeof EditorFeatureQuery>。
function modelToRepData(pipe:IPipingUnitEntity){
  const {id,crDate,name,code,leng,level,start,stop,lay,thik,rno,dia,svp,pa,proj,insd,used,desu,insu}=pipe as any;
  const {材料,设压,设温,直径,腐蚀}=svp;
  const {工介,工压,工温,试压,防腐材,沥青级,防腐厚}=pa;
  //节约存储; 后端报告中：不需要存储usue{id,name}；
  return {
    id,crDate, name,code,leng,level,start,stop,lay,thik,rno,dia,proj,insd,used,desu,insu,
    svp:{材料,设压,设温,直径,腐蚀},
    pa:{工介,工压,工温,试压,防腐材,沥青级,防腐厚}
  };
}

export const OriginalView=
  React.forwardRef((
    { action: modAction,  verId, repId='', rep}
    :OriginalViewProps, ref
  ) => {
    const {list}=useRecordListSubr(ref,rep,recordPrintList,modAction,verId);
    return <React.Fragment>
      {list}
    </React.Fragment>;
  } );
